home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Temático 40 Febrero 2004.iso / DOS / testdisk / src / bsd.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-01-06  |  7.2 KB  |  172 lines

  1. /*
  2.  
  3.     File: bsd.h
  4.  
  5.     Copyright (C) 1998-2004 Christophe GRENIER <grenier@cgsecurity.org>
  6.   
  7.     This software is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.   
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.   
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  */
  22. /* Come mainly from sys/disklabel.h and disktab.h */
  23.  
  24. #ifndef BSDDL_H
  25. #define BSDDL_H
  26.  
  27. #define STANDALONE
  28.  
  29. #define BBSIZE        8192    /* size of boot area, with label */
  30.  
  31. #ifdef __i386__
  32. #define LABELSECTOR    1            /* sector containing label */
  33. #define LABELOFFSET    0            /* offset of label in sector */
  34. #endif
  35.  
  36. #ifndef    LABELSECTOR
  37. #define LABELSECTOR    0            /* sector containing label */
  38. #endif
  39.  
  40. #ifndef    LABELOFFSET
  41. #define LABELOFFSET    64            /* offset of label in sector */
  42. #endif
  43.  
  44. #define DISKMAGIC    ((u_int32_t)0x82564557)    /* The disk magic number */
  45.  
  46. #define    LABEL_PART    2        /* partition containing label */
  47. #define    RAW_PART    2        /* partition containing whole disk */
  48. #define    SWAP_PART    1        /* partition normally containing swap */
  49.  
  50. struct disklabel {
  51.     u_int32_t d_magic;        /* the magic number */
  52.     u_int16_t d_type;        /* drive type */
  53.     u_int16_t d_subtype;        /* controller/d_type specific */
  54.     char      d_typename[16];    /* type name, e.g. "eagle" */
  55.  
  56.     /* 
  57.      * d_packname contains the pack identifier and is returned when
  58.      * the disklabel is read off the disk or in-core copy.
  59.      * d_boot0 and d_boot1 are the (optional) names of the
  60.      * primary (block 0) and secondary (block 1-15) bootstraps
  61.      * as found in /usr/mdec.  These are returned when using
  62.      * getdiskbyname(3) to retrieve the values from /etc/disktab.
  63.      */
  64. #if defined(KERNEL) || defined(STANDALONE)
  65.     char      d_packname[16];        /* pack identifier */ 
  66. #else
  67.     union {
  68.         char    un_d_packname[16];    /* pack identifier */
  69.         struct {
  70.             char *un_d_boot0;    /* primary bootstrap name */
  71.             char *un_d_boot1;    /* secondary bootstrap name */
  72.         } un_b;
  73.     } d_un;
  74. #define d_packname    d_un.un_d_packname
  75. #define d_boot0        d_un.un_b.un_d_boot0
  76. #define d_boot1        d_un.un_b.un_d_boot1
  77. #endif    /* ! KERNEL or STANDALONE */
  78.  
  79.             /* disk geometry: */
  80.     u_int32_t d_secsize;        /* # of bytes per sector */
  81.     u_int32_t d_nsectors;        /* # of data sectors per track */
  82.     u_int32_t d_ntracks;        /* # of tracks per cylinder */
  83.     u_int32_t d_ncylinders;        /* # of data cylinders per unit */
  84.     u_int32_t d_secpercyl;        /* # of data sectors per cylinder */
  85.     u_int32_t d_secperunit;        /* # of data sectors per unit */
  86.  
  87.     /*
  88.      * Spares (bad sector replacements) below are not counted in
  89.      * d_nsectors or d_secpercyl.  Spare sectors are assumed to
  90.      * be physical sectors which occupy space at the end of each
  91.      * track and/or cylinder.
  92.      */
  93.     u_int16_t d_sparespertrack;    /* # of spare sectors per track */
  94.     u_int16_t d_sparespercyl;    /* # of spare sectors per cylinder */
  95.     /*
  96.      * Alternate cylinders include maintenance, replacement, configuration
  97.      * description areas, etc.
  98.      */
  99.     u_int32_t d_acylinders;        /* # of alt. cylinders per unit */
  100.  
  101.             /* hardware characteristics: */
  102.     /*
  103.      * d_interleave, d_trackskew and d_cylskew describe perturbations
  104.      * in the media format used to compensate for a slow controller.
  105.      * Interleave is physical sector interleave, set up by the
  106.      * formatter or controller when formatting.  When interleaving is
  107.      * in use, logically adjacent sectors are not physically
  108.      * contiguous, but instead are separated by some number of
  109.      * sectors.  It is specified as the ratio of physical sectors
  110.      * traversed per logical sector.  Thus an interleave of 1:1
  111.      * implies contiguous layout, while 2:1 implies that logical
  112.      * sector 0 is separated by one sector from logical sector 1.
  113.      * d_trackskew is the offset of sector 0 on track N relative to
  114.      * sector 0 on track N-1 on the same cylinder.  Finally, d_cylskew
  115.      * is the offset of sector 0 on cylinder N relative to sector 0
  116.      * on cylinder N-1.
  117.      */
  118.     u_int16_t d_rpm;        /* rotational speed */
  119.     u_int16_t d_interleave;        /* hardware sector interleave */
  120.     u_int16_t d_trackskew;        /* sector 0 skew, per track */
  121.     u_int16_t d_cylskew;        /* sector 0 skew, per cylinder */
  122.     u_int32_t d_headswitch;        /* head switch time, usec */
  123.     u_int32_t d_trkseek;        /* track-to-track seek, usec */
  124.     u_int32_t d_flags;        /* generic flags */
  125. #define NDDATA 5
  126.     u_int32_t d_drivedata[NDDATA];    /* drive-type specific information */
  127. #define NSPARE 5
  128.     u_int32_t d_spare[NSPARE];    /* reserved for future use */
  129.     u_int32_t d_magic2;        /* the magic number (again) */
  130.     u_int16_t d_checksum;        /* xor of data incl. partitions */
  131.  
  132.             /* filesystem and partition information: */
  133.     u_int16_t d_npartitions;    /* number of partitions in following */
  134.     u_int32_t d_bbsize;        /* size of boot area at sn0, bytes */
  135.     u_int32_t d_sbsize;        /* max size of fs superblock, bytes */
  136.     struct    partition {        /* the partition table */
  137.         u_int32_t p_size;    /* number of sectors in partition */
  138.         u_int32_t p_offset;    /* starting sector */
  139.         u_int32_t p_fsize;    /* filesystem basic fragment size */
  140.         u_int8_t p_fstype;    /* filesystem type, see below */
  141.         u_int8_t p_frag;    /* filesystem fragments per block */
  142.         union {
  143.             u_int16_t cpg;    /* UFS: FS cylinders per group */
  144.             u_int16_t sgs;    /* LFS: FS segment shift */
  145.         } __partition_u1;
  146. #define    p_cpg    __partition_u1.cpg
  147. #define    p_sgs    __partition_u1.sgs
  148.     } d_partitions[BSD_MAXPARTITIONS];    /* actually may be more */
  149. };
  150. #define TST_FS_UNUSED       0               /* unused */
  151. #define TST_FS_SWAP         1               /* swap */
  152. #define TST_FS_V6           2               /* Sixth Edition */
  153. #define TST_FS_V7           3               /* Seventh Edition */
  154. #define TST_FS_SYSV         4               /* System V */
  155. #define TST_FS_V71K         5               /* V7 with 1K blocks (4.1, 2.9) */
  156. #define TST_FS_V8           6               /* Eighth Edition, 4K blocks */
  157. #define TST_FS_BSDFFS       7               /* 4.2BSD fast filesystem */
  158. #define TST_FS_MSDOS        8               /* MSDOS filesystem */
  159. #define TST_FS_BSDLFS       9               /* 4.4BSD log-structured filesystem */
  160. #define TST_FS_OTHER        10              /* in use, but unknown/unsupported */
  161. #define TST_FS_HPFS         11              /* OS/2 high-performance filesystem */
  162. #define TST_FS_ISO9660      12              /* ISO 9660, normally CD-ROM */
  163. #define TST_FS_BOOT         13              /* partition contains bootstrap */
  164. #define TST_FS_VINUM        14              /* Vinum drive */
  165. #define TST_FS_RAID         15              /* RAIDFrame drive */
  166. #define TST_FS_JFS2         21              /* IBM JFS2 */
  167. int check_BSD(t_param_disk *disk_car,t_diskext *partition,const int debug,const unsigned int max_partitions);
  168. int test_BSD(t_param_disk *disk_car, const struct disklabel*bsd_header,t_diskext *partition,const int debug, const int dump_ind, const unsigned int max_partitions);
  169. int recover_BSD(t_param_disk *disk_car, const struct disklabel*bsd_header,t_diskext *partition,const int debug, const int dump_ind);
  170.  
  171. #endif
  172.